package org.afk.sisy;

import java.util.*;

public class SisyProgress
{
	private final List<String> activities = new ArrayList<String>();

	private long storedInAtticCount;
	private long skippedAtticCount;
	private long changeCount;
	private long copyCount;
	private long deleteCount;
	private long primaryFileCount;
	private long primaryFolderCount;
	private long secondaryFileCount;
	private long secondaryFolderCount;
	private long skipCount;
	private long newPrimaryCount;
	private long newSecondaryCount;
	private long errorCount;

	public long getStoredInAtticCount()
	{
		return storedInAtticCount;
	}

	public void setStoredInAtticCount(final long storedInAtticCount)
	{
		this.storedInAtticCount = storedInAtticCount;
	}

	public long getSkippedAtticCount()
	{
		return skippedAtticCount;
	}

	public void setSkippedAtticCount(final long skippedAtticCount)
	{
		this.skippedAtticCount = skippedAtticCount;
	}

	public long getChangeCount()
	{
		return changeCount;
	}

	public void setChangeCount(final long changeCount)
	{
		this.changeCount = changeCount;
	}

	public long getNewSecondaryCount()
	{
		return newSecondaryCount;
	}

	public void setNewSecondaryCount(final long newSecondaryCount)
	{
		this.newSecondaryCount = newSecondaryCount;
	}

	public List<String> getActivities()
	{
		return this.activities;
	}

	public long getBackup()
	{
		return this.storedInAtticCount;
	}

	public long getChanged()
	{
		return this.changeCount;
	}

	public long getCopyCount()
	{
		return this.copyCount;
	}

	public long getDeleteCount()
	{
		return this.deleteCount;
	}

	public long getErrorCount()
	{
		return this.errorCount;
	}

	public long getNewPrimaryCount()
	{
		return this.newPrimaryCount;
	}

	public long getPrimaryFileCount()
	{
		return this.primaryFileCount;
	}

	public long getPrimaryFolderCount()
	{
		return this.primaryFolderCount;
	}

	public long getSecondaryFileCount()
	{
		return this.secondaryFileCount;
	}

	public long getSecondaryFolderCount()
	{
		return this.secondaryFolderCount;
	}

	public long getSkipCount()
	{
		return this.skipCount;
	}

	public void incStoredInAtticCount(final long change)
	{
		this.storedInAtticCount += change;
		fireChange();
	}

	public void incSkippedAtticCount(final long change)
	{
		this.skippedAtticCount += change;
		fireChange();
	}

	public void incChanged(final long change)
	{
		this.changeCount = +change;
	}

	public void incCopied(final long change)
	{
		this.copyCount += change;
		fireChange();
	}

	public void incDeleted(final long change)
	{
		this.deleteCount += change;
		fireChange();
	}

	public void incError(final long change)
	{
		this.errorCount += change;
		fireChange();
	}

	public void incSourceFiles(final long change)
	{
		this.primaryFileCount += change;
		fireChange();

	}

	public void incSourceFolders(final long change)
	{
		this.primaryFolderCount += change;
		fireChange();

	}

	public void incTargetFiles(final long change)
	{
		this.secondaryFileCount += change;
		fireChange();

	}

	public void incTargetFolders(final long change)
	{
		this.secondaryFolderCount += change;
		fireChange();

	}

	public void incSkipped(final long change)
	{
		this.skipCount += change;
		fireChange();
	}

	public void incNewPrimaryCount(final long change)
	{
		newPrimaryCount += change;
		fireChange();
	}

	public void incNewSecondaryCount(final long change)
	{
		newSecondaryCount += change;
		fireChange();
	}

	public void setBackup(final long newValue)
	{
		this.storedInAtticCount = newValue;
		fireChange();
	}

	public void setChanged(final long newValue)
	{
		this.changeCount = newValue;
		fireChange();
	}

	public void setCopyCount(final long newValue)
	{
		this.copyCount = newValue;
		fireChange();
	}

	public void setDeleteCount(final long newValue)
	{
		this.deleteCount = newValue;
		fireChange();
	}

	public void setErrorCount(final long newValue)
	{
		this.errorCount = newValue;
		fireChange();
	}

	public void setNewPrimaryCount(final long newValue)
	{
		newPrimaryCount = newValue;
		fireChange();
	}

	public void setPrimaryFileCount(final long newValue)
	{
		this.primaryFileCount = newValue;
		fireChange();
	}

	public void setPrimaryFolderCount(final long newValue)
	{
		this.primaryFolderCount = newValue;
		fireChange();
	}

	public void setSecondaryFileCount(final long newValue)
	{
		this.secondaryFileCount = newValue;
		fireChange();
	}

	public void setSecondaryFolderCount(final long newValue)
	{
		this.secondaryFolderCount = newValue;
		fireChange();
	}

	public void setSkipCount(final long newValue)
	{
		this.skipCount = newValue;
		fireChange();
	}

	@Override
	public String toString()
	{
		final StringBuilder builder = new StringBuilder();
		builder.append("SisyProgress [");
		if (activities != null)
		{
			builder.append("activities=");
			builder.append(activities);
			builder.append(", ");
		}
		builder.append("storedInAtticCount=");
		builder.append(storedInAtticCount);
		builder.append(", skippedAtticCount=");
		builder.append(skippedAtticCount);
		builder.append(", changeCount=");
		builder.append(changeCount);
		builder.append(", copyCount=");
		builder.append(copyCount);
		builder.append(", deleteCount=");
		builder.append(deleteCount);
		builder.append(", primaryFileCount=");
		builder.append(primaryFileCount);
		builder.append(", primaryFolderCount=");
		builder.append(primaryFolderCount);
		builder.append(", secondaryFileCount=");
		builder.append(secondaryFileCount);
		builder.append(", secondaryFolderCount=");
		builder.append(secondaryFolderCount);
		builder.append(", skipCount=");
		builder.append(skipCount);
		builder.append(", newPrimaryCount=");
		builder.append(newPrimaryCount);
		builder.append(", newSecondaryCount=");
		builder.append(newSecondaryCount);
		builder.append(", errorCount=");
		builder.append(errorCount);
		builder.append("]");
		return builder.toString();
	}

	private final List<SisyProgressListener> listener = Collections.synchronizedList(new ArrayList<SisyProgressListener>());

	public void addListener(final SisyProgressListener sisy)
	{
		if (!listener.contains(sisy))
			listener.add(sisy);
	}

	public boolean removeListener(final SisyProgressListener sisy)
	{
		return listener.remove(sisy);
	}

	private void fireChange()
	{
		synchronized (listener)
		{
			final Iterator<SisyProgressListener> iterator = listener.iterator();
			while (iterator.hasNext())
				iterator.next().progress();
		}
	}
}
